fix(web): preserve scroll when collapsing large changed-files trees#1113
fix(web): preserve scroll when collapsing large changed-files trees#1113CodeZeno wants to merge 1 commit intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip You can get early access to new features in CodeRabbit.Enable the |
Summary
Fix chat scroll jumps when collapsing very large changed-files trees.
Problem
When a changed-files section contains hundreds of entries, collapsing the tree can shrink the rendered message enough that the timeline repositions the viewport unexpectedly. In practice this makes the collapse controls feel broken because the user gets pulled away from the message they were interacting with.
What changed
data-scroll-anchor-ignoreso click-anchor restoration does not interfere with those interactionsWhy
The bug happens during an intentional height change inside the message the user is actively viewing. In that case, preserving the current viewport is more stable than trying to compensate for the size change. The virtualizer can still adjust scroll for off-screen rows, but visible changed-files interactions now keep the user anchored in place.
UI Changes
Before:
https://github.com/user-attachments/assets/60f06a27-9776-4c6d-b553-611fbbf5b2a0
After:
https://github.com/user-attachments/assets/eacd53a5-66f9-41e7-b70c-7b4de1b0292d
Good to have
Might also be nice to have the default as collapsed if the number of changed files is greater then a certain number?
Checklist
Note
Preserve scroll position when collapsing changed-files trees in the chat timeline
data-scroll-anchor-ignoreto directory toggle buttons inChangedFilesTree.tsxand the collapse/expand button inMessagesTimeline.tsxso clicks on these buttons don't trigger scroll anchor adjustments.shouldAdjustScrollPositionOnItemSizeChangeinMessagesTimelineto skip scroll adjustments when the resized item is within the viewport, preventing jarring scroll jumps when collapsing large file trees.AUTO_SCROLL_BOTTOM_THRESHOLD_PX.Macroscope summarized 7b0d5e8.